package com.wocai.jrt.orgadmin.stats.service.impl;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;
import javax.inject.Named;

import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

import com.vteba.utils.common.BigDecimalUtils;
import com.wocai.jrt.admin.common.cache.Const;
import com.wocai.jrt.orgadmin.appointment.model.Appointment;
import com.wocai.jrt.orgadmin.appointment.model.AppointmentBean;
import com.wocai.jrt.orgadmin.appointment.service.spi.AppointmentService;
import com.wocai.jrt.orgadmin.employee.model.Checkin;
import com.wocai.jrt.orgadmin.employee.model.CheckinBean;
import com.wocai.jrt.orgadmin.employee.service.spi.CheckinService;
import com.wocai.jrt.orgadmin.investor.model.Investor;
import com.wocai.jrt.orgadmin.investor.model.InvestorBean;
import com.wocai.jrt.orgadmin.investor.service.spi.InvestorService;
import com.wocai.jrt.orgadmin.orders.model.Orders;
import com.wocai.jrt.orgadmin.orders.model.OrdersBean;
import com.wocai.jrt.orgadmin.orders.service.spi.OrdersService;
import com.wocai.jrt.orgadmin.stats.service.spi.RedisCacheEmpStatsService;

@Named
public class RedisCacheEmpStatsServiceImpl implements RedisCacheEmpStatsService {
	private static final Logger LOGGER = LoggerFactory
			.getLogger(RedisCacheEmpStatsServiceImpl.class);
	@Inject
	private InvestorService investorServiceImpl;
	@Inject
	private AppointmentService appointmentServiceImpl;
	@Inject
	private CheckinService checkinServiceImpl;
	@Inject
	private OrdersService ordersServiceImpl;

	/**
	 * 查询当前Employee这个月的投资人数，按每天的人数返回
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_INVERSTOR + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<List<String>> queryInvestorNumList(String employeeId, String date) {
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryInvestorNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);

		InvestorBean investorBean = new InvestorBean();
		investorBean.createCriteria().andEmployeeIdEqualTo(employeeId).andDeletedEqualTo(false)
				.andRegisterTimeBetween(startTime.toDate(), endTime.toDate());
		List<Investor> investorList = investorServiceImpl.queryForList(investorBean);
		// 统计人数
		List<List<String>> dataMonth = new ArrayList<List<String>>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			List<String> dataDay = new ArrayList<String>();
			dataMonth.add(dataDay);
		}
		for (Investor investor : investorList) {
			DateTime tempdDateTime = new DateTime(investor.getRegisterTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			List<String> dataDay = dataMonth.get(tempDays);
			dataDay.add(investor.getId());
			dataMonth.set(tempDays, dataDay);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee这个月的预约数，按每天的人数返回
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_APPOINTMENT + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryAppointmentNumList(String employeeId, String date) {
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryAppointmentNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);

		AppointmentBean appointmentBean = new AppointmentBean();
		appointmentBean.createCriteria().andEmployeeIdEqualTo(employeeId)
				.andCreateTimeBetween(startTime.toDate(), endTime.toDate());
		List<Appointment> appointmentList = appointmentServiceImpl.queryForList(appointmentBean);
		// 统计人数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Appointment appointment : appointmentList) {
			DateTime tempdDateTime = new DateTime(appointment.getCreateTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee已有成交的投资人
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_DEALINVERSTOR
			+ "+ #employeeId")
	public List<String> queryDealInvestorList(String employeeId) {
		LOGGER.info("RedisCacheEmpStatsServiceImpl queryDealInvestorList, employeeId=[{}]",
				employeeId);
		Investor investor = new Investor();
		investor.setEmployeeId(employeeId);
		List<Investor> totalInvestorList = investorServiceImpl.queryList(investor);
		List<String> values = new ArrayList<String>();
		for (Investor investor2 : totalInvestorList) {
			values.add(investor2.getId());
		}
		OrdersBean ordersBean = new OrdersBean();
		
		List<Orders> orderList = new ArrayList<Orders>();
		if (values.size() > 0) {
			ordersBean.createCriteria().andStateEqualTo(6).andInvestorIdIn(values);
			orderList = ordersServiceImpl.queryForList(ordersBean);
		}
//		if (values.size()>0) {
//			ordersBean.createCriteria().andStateEqualTo(6).andInvestorIdIn(values);
//		} else {
//			ordersBean.createCriteria().andStateEqualTo(6);
//		}
//		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		Set<String> dealInvestorIdSet = new HashSet<String>();
		for (Orders orders : orderList) {
			dealInvestorIdSet.add(orders.getInvestorId());
		}
		List<String> dealInvestorIdList = new ArrayList<String>();
		for (String string : dealInvestorIdSet) {
			dealInvestorIdList.add(string);
		}
		return dealInvestorIdList;
	}

	/**
	 * 查询当前Employee的签到次数列表，返回这个月的每天签到次数
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_CHECKIN + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryCheckinNumList(String employeeId, String date) {
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		CheckinBean checkinBean = new CheckinBean();
		checkinBean.createCriteria().andEmployeeIdEqualTo(employeeId)
				.andSignTimeBetween(startTime.toDate(), endTime.toDate());
		List<Checkin> checkinList = checkinServiceImpl.queryForList(checkinBean);
		// 统计人数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Checkin checkin : checkinList) {
			DateTime tempdDateTime = new DateTime(checkin.getSignTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee总订单数（完成，未完成），返回这个月每天的订单数
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_ORDERSTOTAL + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryOrdersTotalNumList(String employeeId, String date) {
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		OrdersBean ordersBean = new OrdersBean();
		ordersBean.createCriteria().andEmployeeIdEqualTo(employeeId)
				.andOrderTimeBetween(startTime.toDate(), endTime.toDate());
		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		// 统计订单数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Orders orders : orderList) {
			DateTime tempdDateTime = new DateTime(orders.getOrderTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee订单数（完成），返回这个月每天的订单数
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_ORDERS + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryOrdersNumList(String employeeId, String date) {
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		OrdersBean ordersBean = new OrdersBean();
		ordersBean.createCriteria().andEmployeeIdEqualTo(employeeId).andStateEqualTo(6)
				.andOrderTimeBetween(startTime.toDate(), endTime.toDate());
		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		// 统计订单数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Orders orders : orderList) {
			DateTime tempdDateTime = new DateTime(orders.getOrderTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee订单（完成）的金额，返回这个月每天的订单金额
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@Cacheable(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_ORDERSAMOUNT
			+ "+ #employeeId" + "+ '_'" + "+ #date")
	public List<Double> queryOrdersAmountList(String employeeId, String date) {
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		OrdersBean ordersBean = new OrdersBean();
		ordersBean.createCriteria().andEmployeeIdEqualTo(employeeId).andStateEqualTo(6)
				.andOrderTimeBetween(startTime.toDate(), endTime.toDate());
		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		// 统计订单金额
		List<Double> dataMonth = new ArrayList<Double>();
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0D);
		}
		for (Orders orders : orderList) {
			DateTime tempdDateTime = new DateTime(orders.getOrderTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays,
					BigDecimalUtils.add(dataMonth.get(tempDays), orders.getOrderAmount()));
		}
		return dataMonth;
	}

	// ////////////////////////////////////////////////////////////////
	/**
	 * 查询当前Employee这个月的投资人数，按每天的人数返回
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_INVERSTOR + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<List<String>> queryInvestorNumListCachePut(String employeeId, String date) {
		LOGGER.info("更新缓存:EmployeeInvestorNumList");
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryInvestorNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);

		InvestorBean investorBean = new InvestorBean();
		investorBean.createCriteria().andEmployeeIdEqualTo(employeeId).andDeletedEqualTo(false)
				.andRegisterTimeBetween(startTime.toDate(), endTime.toDate());
		List<Investor> investorList = investorServiceImpl.queryForList(investorBean);
		// 统计人数
		List<List<String>> dataMonth = new ArrayList<List<String>>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			List<String> dataDay = new ArrayList<String>();
			dataMonth.add(dataDay);
		}
		for (Investor investor : investorList) {
			DateTime tempdDateTime = new DateTime(investor.getRegisterTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			List<String> dataDay = dataMonth.get(tempDays);
			dataDay.add(investor.getId());
			dataMonth.set(tempDays, dataDay);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee这个月的预约数，按每天的人数返回
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_APPOINTMENT + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryAppointmentNumListCachePut(String employeeId, String date) {
		LOGGER.info("更新缓存:EmployeeAppointmentNumList");
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryAppointmentNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);

		AppointmentBean appointmentBean = new AppointmentBean();
		appointmentBean.createCriteria().andEmployeeIdEqualTo(employeeId)
				.andCreateTimeBetween(startTime.toDate(), endTime.toDate());
		List<Appointment> appointmentList = appointmentServiceImpl.queryForList(appointmentBean);
		// 统计人数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Appointment appointment : appointmentList) {
			DateTime tempdDateTime = new DateTime(appointment.getCreateTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee已有成交的投资人
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_DEALINVERSTOR
			+ "+ #employeeId")
	public List<String> queryDealInvestorListCachePut(String employeeId) {
		LOGGER.info("更新缓存:EmployeeDealInvestorList");
		LOGGER.info("RedisCacheEmpStatsServiceImpl queryDealInvestorList, employeeId=[{}]",
				employeeId);
		Investor investor = new Investor();
		investor.setEmployeeId(employeeId);
		List<Investor> totalInvestorList = investorServiceImpl.queryList(investor);
		List<String> values = new ArrayList<String>();
		for (Investor investor2 : totalInvestorList) {
			values.add(investor2.getId());
		}
		OrdersBean ordersBean = new OrdersBean();
		List<Orders> orderList = new ArrayList<Orders>();
		if (values.size() > 0) {
			ordersBean.createCriteria().andStateEqualTo(6).andInvestorIdIn(values);
			orderList = ordersServiceImpl.queryForList(ordersBean);
		}
		Set<String> dealInvestorIdSet = new HashSet<String>();
		for (Orders orders : orderList) {
			dealInvestorIdSet.add(orders.getInvestorId());
		}
		List<String> dealInvestorIdList = new ArrayList<String>();
		for (String string : dealInvestorIdSet) {
			dealInvestorIdList.add(string);
		}
		return dealInvestorIdList;
	}

	/**
	 * 查询当前Employee的签到次数列表，返回这个月的每天签到次数
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_CHECKIN + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryCheckinNumListCachePut(String employeeId, String date) {
		LOGGER.info("更新缓存:EmployeeCheckinNumList");
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		CheckinBean checkinBean = new CheckinBean();
		checkinBean.createCriteria().andEmployeeIdEqualTo(employeeId)
				.andSignTimeBetween(startTime.toDate(), endTime.toDate());
		List<Checkin> checkinList = checkinServiceImpl.queryForList(checkinBean);
		// 统计人数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Checkin checkin : checkinList) {
			DateTime tempdDateTime = new DateTime(checkin.getSignTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee总订单数（完成，未完成），返回这个月每天的订单数
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_ORDERSTOTAL + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryOrdersTotalNumListCachePut(String employeeId, String date) {
		LOGGER.info("更新缓存:EmployeeOrdersTotalNumList");
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		OrdersBean ordersBean = new OrdersBean();
		ordersBean.createCriteria().andEmployeeIdEqualTo(employeeId)
				.andOrderTimeBetween(startTime.toDate(), endTime.toDate());
		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		// 统计订单数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Orders orders : orderList) {
			DateTime tempdDateTime = new DateTime(orders.getOrderTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee订单数（完成），返回这个月每天的订单数
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_ORDERS + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Integer> queryOrdersNumListCachePut(String employeeId, String date) {
		LOGGER.info("更新缓存:EmployeeOrdersNumList");
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		OrdersBean ordersBean = new OrdersBean();
		ordersBean.createCriteria().andEmployeeIdEqualTo(employeeId).andStateEqualTo(6)
				.andOrderTimeBetween(startTime.toDate(), endTime.toDate());
		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		// 统计订单数
		List<Integer> dataMonth = new ArrayList<Integer>();// 每天的人数汇总放这儿
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0);
		}
		for (Orders orders : orderList) {
			DateTime tempdDateTime = new DateTime(orders.getOrderTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays, dataMonth.get(tempDays) + 1);
		}
		return dataMonth;
	}

	/**
	 * 查询当前Employee订单（完成）的金额，返回这个月每天的订单金额
	 * 
	 * @param id
	 * @param beginDateTime
	 * @return
	 */
	@Override
	@CachePut(value = Const.STATS, key = Const.PREFIX_EMPLOYEE_STATS_ORDERSAMOUNT + "+ #employeeId"
			+ "+ '_'" + "+ #date")
	public List<Double> queryOrdersAmountListCachePut(String employeeId, String date) {
		LOGGER.info("更新缓存:EmployeeOrdersAmountList");
		DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
		DateTime startTime = DateTime.parse(date, formatter);
		DateTime endTime = startTime.plusMonths(1).minusMillis(1);
		LOGGER.info(
				"RedisCacheEmpStatsServiceImpl queryCheckinNumList, startTime=[{}], endTime=[{}]",
				startTime, endTime);
		OrdersBean ordersBean = new OrdersBean();
		ordersBean.createCriteria().andEmployeeIdEqualTo(employeeId).andStateEqualTo(6)
				.andOrderTimeBetween(startTime.toDate(), endTime.toDate());
		List<Orders> orderList = ordersServiceImpl.queryForList(ordersBean);
		// 统计订单金额
		List<Double> dataMonth = new ArrayList<Double>();
		int days = Days.daysBetween(startTime, endTime).getDays();
		for (int i = 0; i <= days; i++) {
			dataMonth.add(0D);
		}
		for (Orders orders : orderList) {
			DateTime tempdDateTime = new DateTime(orders.getOrderTime());
			int tempDays = Days.daysBetween(startTime, tempdDateTime).getDays();
			dataMonth.set(tempDays,
					BigDecimalUtils.add(dataMonth.get(tempDays), orders.getOrderAmount()));
		}
		return dataMonth;
	}
}
